package org.learn.phase3.udp;

import java.io.IOException;
import java.net.*;

public class UDPSenderB {
    public static void main(String[] args) throws IOException {

        //创建  对象，准备在9998端口接收数据
        DatagramSocket socket = new DatagramSocket(9998);

        //封装数据到 对象
        byte[] data = "hello,明天吃火锅~~".getBytes();

        //封装的对象 data 内容字节数组 data.length 主机ip 端口
        DatagramPacket packet = new DatagramPacket
                (data, data.length, InetAddress.getByName("192.168.10.252"), 9999);

        socket.send(packet);

        //关闭资源
        socket.close();
        System.out.println("b端退出");

    }
}
